package com.oa.hyperion.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oa.hyperion.entity.assets.AssetsAllocation;
import com.oa.hyperion.entity.assets.AssetsDetail;
import com.oa.hyperion.repository.assets.AssetsDetailMapper;
import com.oa.hyperion.service.AssetsDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AssetsDetailServiceImpl implements AssetsDetailService {

    @Autowired
    private AssetsDetailMapper assetsDetailMapper;

    @Override
    public void insert(AssetsDetail assetsDetail) {
        assetsDetailMapper.insert(assetsDetail);
    }

    @Override
    public boolean update(AssetsDetail assetsDetail) {
        return assetsDetailMapper.update(assetsDetail);
    }

    @Override
    public List<AssetsDetail> getAllDetails() {
        return assetsDetailMapper.getAllDetails();
    }

    @Override
    public List<AssetsDetail> getAssetsDetailByAssetId(int asset_id) {
        return assetsDetailMapper.getAssetsDetailByAssetId(asset_id);
    }

    @Override
    public List<AssetsDetail> getAssetsDetailByApplydpt(int apply_dpt) {
        return assetsDetailMapper.getAssetsDetailByApplydpt(apply_dpt);
    }

    @Override
    public List<AssetsDetail> getAssetsDetailByHandler(String handler) {
        return assetsDetailMapper.getAssetsDetailByHandler(handler);
    }

    @Override
    public List<AssetsDetail> getAssetsDetailByReturned(String returned) {
        return assetsDetailMapper.getAssetsDetailByReturned(returned);
    }

    @Override
    public PageInfo<AssetsDetail> getByCondition(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<AssetsDetail> assetsDetails = assetsDetailMapper.getAllDetails();
        return new PageInfo<>(assetsDetails);
    }
}
